

import java.io.*;


public class fuzhi {

    private final static String url_1 = "Curriculum07/src/fuzhi1.txt";
    private final static String url_2 = "Curriculum07/src/fuzhi2.txt";

    //use BufferedReader and BufferedWriter
    public static void main(String[] args) {

        useBufferedWriter(url_1, url_2);

    }


    public static int useBufferedWriter(String from_url, String to_url) {
        String thisLine;
        int count = 0;
        try {
            FileReader fileReader = new FileReader(from_url);
            FileWriter fileWriter = new FileWriter(to_url);
            BufferedReader bufferedReader = new BufferedReader(fileReader);
            BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
            while ((thisLine = bufferedReader.readLine()) != null) {
                count++;
                System.out.println(thisLine);
                System.out.println(count + " " + thisLine);
                bufferedWriter.write(count + " " + thisLine);
                bufferedWriter.newLine();
            }
            bufferedWriter.flush();
            System.out.println("读取" + count + "行. \n写入" + count + "行");
        } catch (IOException e) {
            e.printStackTrace();
            return 0;
        }
        return 1;
    }
}